package com.briup.smartcity_group6.utils;

/**
 * 为了生成Result对象生成工具类
 */

    public class ResultUtil {
        private ResultUtil() {}

        public static Result success(){//默认成功
            return new Result(ResultCode.SUCCESS);
        }
        public static Result success(Object data){
            return new Result(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMsg(),data);
        }
        public static Result success(ResultCode code){
            return new Result(code.getCode(),code.getMsg());
        }


        //失败-----------
        public static Result error(){//默认成功
            return new Result(ResultCode.ERROR);
        }
        public static Result error(Object data){
            return new Result(ResultCode.ERROR.getCode(),ResultCode.ERROR.getMsg(),data);
        }
        public static Result error(String msg){
            return new Result(ResultCode.ERROR.getCode(),msg);
        }
        public static Result error(ResultCode code){
            return new Result(code);
        }

}
